package org.agile2soft.nexoma.core.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.agile2soft.nexoma.expedient.entity.EntryReg;
import org.agile2soft.nexoma.expedient.entity.ExpedientDoc;
import org.agile2soft.nexoma.expedient.entity.ExpedientTypePhaseExpedients;

@Entity
@Table(name = "INTERNAL_USER", uniqueConstraints = @UniqueConstraint(columnNames = "IUS_DOCUMENT_NUMBER"))
@SuppressWarnings({"serial"})
public class InternalUser implements java.io.Serializable {

    private String login;
    private Profile profile;
    private String password;
    private String documentNumber;
    private String name;
    private String surname1;
    private String surname2;
    private String job;
    private String extension;
    private String email;
    private boolean active;
    private boolean attemptsNumber;
    private Set<EntryReg> entryRegs = new HashSet<EntryReg>(0);
    private Set<ExpedientDoc> expedientDocs = new HashSet<ExpedientDoc>(0);
    private Set<ExpedientTypePhaseExpedients> expedientTypePhaseExpedients = new HashSet<ExpedientTypePhaseExpedients>();

    public InternalUser() {
    }

    public InternalUser(String login, Profile profile,
            String password,
            String documentNumber, String name, String surname1,
            String job, String extension, String email,
            boolean status,  boolean attempsNumber) {
        this.login = login;
        this.profile = profile;
        this.password = password;
        this.documentNumber = documentNumber;
        this.name = name;
        this.surname1 = surname1;
        this.job = job;
        this.extension = extension;
        this.email = email;
        this.active = status;
        this.attemptsNumber = attempsNumber;
    }

    public InternalUser(String login, Profile perfiles,
            String password, String documentNumber, String name, String surname1,
            String surname2, String job, String extension,
            String email, boolean status,
            boolean attempsNumber,
            Set<EntryReg> entryRegs,
            Set<ExpedientDoc> expDocuments,
            Set<ExpedientTypePhaseExpedients> expedientTypePhaseExpedients) {
        this.login = login;
        this.profile = perfiles;
        this.password = password;
        this.documentNumber = documentNumber;
        this.name = name;
        this.surname1 = surname1;
        this.surname2 = surname2;
        this.job = job;
        this.extension = extension;
        this.email = email;
        this.active = status;
        this.attemptsNumber = attempsNumber;
        this.entryRegs = entryRegs;
        this.expedientDocs = expDocuments;
        this.expedientTypePhaseExpedients = expedientTypePhaseExpedients;
    }

    @Id
    @Column(name = "IUS_LOGIN", unique = true, nullable = false, length = 15)
    public String getLogin() {
        return this.login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "PER_ID", nullable = false)
    public Profile getProfile() {
        return this.profile;
    }

    public void setProfile(Profile profile) {
        this.profile = profile;
    }

    @Column(name = "IUS_PASSWORD", nullable = false, length = 40)
    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(name = "IUS_DOCUMENT_NUMBER", unique = true, nullable = false, length = 25)
    public String getDocumentNumber() {
        return this.documentNumber;
    }

    public void setDocumentNumber(String documentNumber) {
        this.documentNumber = documentNumber;
    }

    @Column(name = "IUS_NAME", nullable = false, length = 30)
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "IUS_SURNAME1", nullable = true, length = 50)
    public String getSurname1() {
        return this.surname1;
    }

    public void setSurname1(String surname1) {
        this.surname1 = surname1;
    }

    @Column(name = "IUS_SURNAME2", length = 50)
    public String getSurname2() {
        return this.surname2;
    }

    public void setSurname2(String surname2) {
        this.surname2 = surname2;
    }

    @Column(name = "IUS_JOB", nullable = true, length = 100)
    public String getJob() {
        return this.job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    @Column(name = "IUS_EXTENSION", nullable = true, length = 50)
    public String getExtension() {
        return this.extension;
    }

    public void setExtension(String extension) {
        this.extension = extension;
    }

    @Column(name = "IUS_EMAIL", nullable = false, length = 50)
    public String getEmail() {
        return this.email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Column(name = "IUS_ACTIVE", nullable = false)
    public boolean isActive() {
        return this.active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }


    @Column(name = "IUS_ATTEMPTS_NUMBER", nullable = false)
    public boolean isAttempsNumber() {
        return this.attemptsNumber;
    }

    public void setAttempsNumber(boolean attempsNumber) {
        this.attemptsNumber = attempsNumber;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "internalUser")
    public Set<EntryReg> getEntryRegs() {
        return this.entryRegs;
    }

    public void setEntryRegs(Set<EntryReg> entryRegs) {
        this.entryRegs = entryRegs;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "internalUser")
    public Set<ExpedientDoc> getExpedientDocs() {
        return this.expedientDocs;
    }

    public void setExpedientDocs(Set<ExpedientDoc> expedientDocs) {
        this.expedientDocs = expedientDocs;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "internalUser")
    public Set<ExpedientTypePhaseExpedients> getExpedientTypePhaseExpedients() {
        return this.expedientTypePhaseExpedients;
    }

    public void setExpedientTypePhaseExpedients(Set<ExpedientTypePhaseExpedients>expedientTypePhaseExpedients) {
        this.expedientTypePhaseExpedients = expedientTypePhaseExpedients;
    }

}
